<?php $section = 'Users'; ?>
<?php require_once '../inc/functions.php'; ?>
<?php require_once 'data.php'; ?>
<?php 
	$FirstName =  (string)$_POST['FirstName'];
	$LastName = (string)$_POST['LastName'];
	$Email = (string)$_POST['Email'];
	$Password = (string)$_POST['Password'];
	$PhoneNumber = (string)$_POST['PhoneNumber'];
	$Facebook = (string)$_POST['Facebook'];
//	$Street = (string)$_POST['Street'];
//	$City = (string)$_POST['City'];
//	$State = (string)$_POST['State'];
//	$ZipCode = (string)$_POST['ZipCode'];
//	$bStreet = (string)$_POST['bStreet'];
//	$bCity = (string)$_POST['bCity'];
//	$bState = (string)$_POST['bState'];
//	$bZipCode = (string)$_POST['bZipCode'];
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Core[nerd]-Users</title>
<link href="../inc/main.css" rel="stylesheet" type="text/css">
</head>

<body>
<div id="container">

<?php include('../inc/nav.php'); ?>

<?php
	$mysqldate = date('Y-m-d h:i:s');
	$conn = getConnection();
	$sql = "INSERT INTO 2011_Users (FirstName, LastName, Password, Type_id, created_at, updated_at) VALUES ("."'$FirstName', '$LastName', '$Password', '2', '$mysqldate', '0000-00-00 00:00:00' )"; 
	$conn->query($sql);
	$error = $conn->error;	
	echo $error;
	$conn->close();
?>
<?php
	$conn = getConnection();
	$result = $conn->query("SELECT * FROM 2011_Users WHERE Password = '$Password'");
	$rs = $result->fetch_assoc();
	$userId = $rs['id'];
	echo $userId;
	$sql = "INSERT INTO 2011_ContactMethods (User_id, Email, Phone, Facebook) VALUES ('$userId','$Email','$PhoneNumber','$Facebook')"; 
	$conn->query($sql);
	$error = $conn->error;
	echo $error;
	$conn->close();
?>

<?php
	$conn = getConnection();
	$result = $conn->query("SELECT * FROM 2011_Users WHERE Password = '$Password'");
	$rs = $result->fetch_assoc();
	$userId = $rs['id'];
	$sql = "INSERT INTO 2011_Addresses (User_id, Street, City, State, ZipCode, Type_id) VALUES ('$userId', '$Street', '$City', '$State', '$ZipCode', '4')";		
	$conn->query($sql);
	$error = $conn->error;	
	echo $error;
	$conn->close();
?>

<?php
	$userId = GetUserId($LastName, $Password);
	$conn = getConnection();
	$sql = "INSERT INTO 2011_Addresses (User_id, Street, City, State, ZipCode, Type_id) VALUES ('$userId', '$bStreet', '$bCity', '$bState', '$bZipCode','5')";
	$conn->query($sql);
	$error = $conn->error;
	echo $error;
	$conn->close();
?>

<h1>User Added!</h1>

</div>
</body>

</html>
